In [1]:
using FileIO: load, save
import LibSndFile
using Plots
pyplot();
In [2]:
run(`afinfo birdland_original.wav`)
File:           birdland_original.wav
File type ID:   WAVE
Num Tracks:     1
----
Data format:     2 ch,  44100 Hz, 'lpcm' (0x0000000C) 16-bit little-endian signed integer
                no channel layout.
estimated duration: 12.240317 sec
audio bytes: 2159192
audio packets: 539798
bit rate: 1411200 bits per second
packet size upper bound: 4
maximum packet size: 4
audio data file offset: 44
not optimized
source bit depth: I16
----
Out[2]:
Process(`afinfo birdland_original.wav`, ProcessExited(0))
In [3]:
sndorg = load("birdland_original.wav")
Out[3]:

SampleBuf display requires javascript

To enable for the whole notebook select "Trust Notebook" from the "File" menu. You can also trust this cell by re-running it. You may also need to re-run `using SampledSignals` if the module is not yet loaded in the Julia kernel, or `SampledSignals.embed_javascript()` if the Julia module is loaded but the javascript isn't initialized.

In [4]:
run(`afconvert -f mp4f birdland_original.wav -o birdland.mp4`);
In [5]:
run(`afinfo birdland.mp4`);
File:           birdland.mp4
File type ID:   mp4f
Num Tracks:     1
----
Data format:     2 ch,  44100 Hz, 'aac ' (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
                no channel layout.
estimated duration: 12.240317 sec
audio bytes: 200206
audio packets: 530
bit rate: 130145 bits per second
packet size upper bound: 682
maximum packet size: 682
audio data file offset: 4096
optimized
audio 539798 valid frames + 2112 priming + 810 remainder = 542720
format list:
[ 0] format:	  2 ch,  44100 Hz, 'aac ' (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
Channel layout: Stereo (L R)
----
In [6]:
run(`afconvert -f WAVE -d LEI16 birdland.mp4 birdland_aac.wav`);
In [7]:
run(`afinfo birdland_aac.wav`);
File:           birdland_aac.wav
File type ID:   WAVE
Num Tracks:     1
----
Data format:     2 ch,  44100 Hz, 'lpcm' (0x0000000C) 16-bit little-endian signed integer
                no channel layout.
estimated duration: 12.240317 sec
audio bytes: 2159192
audio packets: 539798
bit rate: 1411200 bits per second
packet size upper bound: 4
maximum packet size: 4
audio data file offset: 4096
optimized
source bit depth: I16
----
In [8]:
sndaac = load("birdland_aac.wav")
Out[8]:

SampleBuf display requires javascript

To enable for the whole notebook select "Trust Notebook" from the "File" menu. You can also trust this cell by re-running it. You may also need to re-run `using SampledSignals` if the module is not yet loaded in the Julia kernel, or `SampledSignals.embed_javascript()` if the Julia module is loaded but the javascript isn't initialized.

In [9]:
sndmp3 = load("birdland_mp3.wav")
Out[9]:

SampleBuf display requires javascript

To enable for the whole notebook select "Trust Notebook" from the "File" menu. You can also trust this cell by re-running it. You may also need to re-run `using SampledSignals` if the module is not yet loaded in the Julia kernel, or `SampledSignals.embed_javascript()` if the Julia module is loaded but the javascript isn't initialized.

In [10]:
xorg = sndorg.data[:,1];
xaac = sndaac.data[:,1];
fs = sndorg.samplerate;
t = (0 : length(xorg)-1) / fs;
In [11]:
snddif = sndorg - sndaac
Out[11]:

SampleBuf display requires javascript

To enable for the whole notebook select "Trust Notebook" from the "File" menu. You can also trust this cell by re-running it. You may also need to re-run `using SampledSignals` if the module is not yet loaded in the Julia kernel, or `SampledSignals.embed_javascript()` if the Julia module is loaded but the javascript isn't initialized.

In [12]:
sndorg - sndmp3
Out[12]:

SampleBuf display requires javascript

To enable for the whole notebook select "Trust Notebook" from the "File" menu. You can also trust this cell by re-running it. You may also need to re-run `using SampledSignals` if the module is not yet loaded in the Julia kernel, or `SampledSignals.embed_javascript()` if the Julia module is loaded but the javascript isn't initialized.